<%@page import="com.xnx3.j2ee.Global"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
<%@ taglib uri="http://www.xnx3.com/java_xnx3/xnx3_tld" prefix="x" %>
<jsp:include page="/wm/common/head.jsp">
	<jsp:param name="title" value="用户列表"/>
</jsp:include>
<style>
	img{
		width:30px;
		height:30px;	
	}
</style>
<script src="/<%=Global.CACHE_FILE %>Role_role.js"></script>

		<a class="layui-btn layui-btn-normal" onclick="getChengdanExecl();" style="float: right;  margin:5px">导出excel</a>	
</form>


<table class="layui-table iw_table">
  <thead>
    <tr>
        <th>用户编号</th>
        <th>用户等级</th>
        <th>用户昵称</th>
        <th>用户手机号</th>
        <th>用户头像</th>
        <th>下单数</th>
        <th>总重量(kg)</th>
        <th>总金额(元)</th>
        <th>注册时间</th>
        <th>操作</th>    
    </tr> 
  </thead>
  <tbody>
  	<c:forEach items="${list}" var="user">
  		<tr>
          <td >${user.id }</td>
          <td >${user.grade }</td>
          <td >${user.nickname }</td>
          <td >${user.phone }</td>
          <td style="text-align:center;">
				<a href="${user.head}" target="_black"><img src = '${user.head }' /></a>
		  </td>
          <td>${user.allOrderNumbe }</td>
          <td>${user.allSellWgight /1000}</td>
          <td>${user.allIncomeMone /100}</td>
          <td><x:time linuxTime="${user.regtime }" format="yy-MM-dd HH:mm"></x:time></td>
          <td>
          		<botton class="layui-btn layui-btn-sm" onclick="editRole(${user.id }, '${user.nickname }');" style="margin-left: 3px;">订单记录</botton>
          </td>
      </tr>
    </c:forEach>
  </tbody>
</table>
<!-- 通用分页跳转 -->
<jsp:include page="/wm/common/page.jsp"></jsp:include>

<script type="text/javascript">

//订单记录
function editRole(id, nickname){
	layer.open({
		type: 2, 
		title:'订单记录', 
		area: ['90%','90%'],
		shadeClose: true, //开启遮罩关闭
		content: '/admin/user/orderList.jsp?userid='+id
	});
}

/**
 * 对象转url参数
 * @param {*} data,对象
 * @param {*} isPrefix,是否自动加上"?"
 */
function queryParams(data = {}, isPrefix = true, arrayFormat = 'brackets') {
    let prefix = isPrefix ? '?' : ''
    let _result = []
    if (['indices', 'brackets', 'repeat', 'comma'].indexOf(arrayFormat) == -1) arrayFormat = 'brackets';
    for (let key in data) {
        let value = data[key]
        // 去掉为空的参数
        if (['', undefined, null].indexOf(value) >= 0) {
            continue;
        }
        // 如果值为数组，另行处理
        if (value.constructor === Array) {
            // e.g. {ids: [1, 2, 3]}
            switch (arrayFormat) {
                case 'indices':
                    // 结果: ids[0]=1&ids[1]=2&ids[2]=3
                    for (let i = 0; i < value.length; i++) {
                        _result.push(key + '[' + i + ']=' + value[i])
                    }
                    break;
                case 'brackets':
                    // 结果: ids[]=1&ids[]=2&ids[]=3
                    value.forEach(_value => {
                        _result.push(key + '[]=' + _value)
                    })
                    break;
                case 'repeat':
                    // 结果: ids=1&ids=2&ids=3
                    value.forEach(_value => {
                        _result.push(key + '=' + _value)
                    })
                    break;
                case 'comma':
                    // 结果: ids=1,2,3
                    let commaStr = "";
                    value.forEach(_value => {
                        commaStr += (commaStr ? "," : "") + _value;
                    })
                    _result.push(key + '=' + commaStr)
                    break;
                default:
                    value.forEach(_value => {
                        _result.push(key + '[]=' + _value)
                    })
            }
        } else {
            _result.push(key + '=' + value)
        }
    }
    return _result.length ? prefix + _result.join('&') : ''
}


//导出execl
function getChengdanExecl(){
	var data = wm.getJsonObjectByForm($('.toubu_xnx3_search_form'));
	 window.open('/agency/outdoc/getUserExecl.json' + queryParams(data)); 
} 
</script>

<jsp:include page="/wm/common/foot.jsp"></jsp:include>